import { baseUrl } from '@/constants';
import { Button, Card, Divider, Image, Upload } from 'antd';
import React, { useState } from 'react';

const Face: React.FC<API.InterfaceInfo> = (props) => {
  console.log(props);
  const [imgUrl, setImgUrl] = useState<string>('');
  console.log(`${baseUrl}${props.url}`);
  const upProps = {
    name: 'multipartFile',
    action: `${baseUrl}${props.url}`,
    headers: {
      token: localStorage.getItem('token') || '',
    },
    onChange(info: any) {
      if (info.file.status === 'done') {
        setImgUrl(info.file.response.url);
      }
    },
  };
  return (
    <>
      <Card title="在线测试">
        <Upload {...upProps}>
          <Button>点击上传</Button>
        </Upload>
      </Card>
      <Divider />
      <Card title="返回结果">
        <Image src={imgUrl} />
      </Card>
    </>
  );
};

export default Face;
